<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>修改文章分类 - bjyadmin</title>
    <link rel="stylesheet" href="__ADMIN_STATICS__/bootstrap/dist/css/bootstrap.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/animate.css/animate.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/font-awesome/css/font-awesome.min.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/simple-line-icons/css/simple-line-icons.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/bootstrap-editable/css/bootstrap-editable.min.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/app/css/font.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/app/css/app.css" type="text/css" />
    <webuploadercss/>
</head>
<body>
<div class="wrapper-md">
    <div class="panel panel-default">
        <div class="panel-heading">
            <a href="{:U('Admin/Index/welcome')}"><i class="fa fa-home"></i>&nbsp;首页&nbsp;</a>&gt;&nbsp;
            <a href="{:U('Admin/ArticleCategory/index')}">文章分类列表</a>&nbsp;&gt;&nbsp;&nbsp;修改文章分类
        </div>
        <div class="table-responsive">
            <form class="form-horizontal" action="{:U('Admin/ArticleCategory/edit')}" method="post">
                <ul class="nav nav-tabs text-center" role="tablist">
                    <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">基础信息</a></li>
                    <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">拓展字段</a></li>
                    <li role="presentation"><a href="#config" aria-controls="config" role="tab" data-toggle="tab">设置</a></li>
                </ul>
                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane active" id="home">
                        <input type="hidden" name="id" value="{$data['id']}">
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label" for="input-id-1">分类名</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="name" value="{$data['name']}" data-form-un="1470118834084.755">
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label">上级分类</label>
                            <div class="col-sm-6">
                                <select name="pid" class="form-control">
                                    <option value="0">顶级分类</option>
                                    <volist id="category" name="allCategory">
                                        <option value="{$category.id}" <if condition="$data['pid'] == $category['id']">selected</if>>{$category['_name']}</option>
                                    </volist>
                                </select>
                            </div>
                        </div>
                         <if condition="$data['pic_path'] neq null">
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group m-b-none m-l-none m-r-none">
                                <label class="col-sm-2 control-label">已上传主图</label>
                                <div class="col-sm-6 v-m">
                                    <img src="{$data['pic_path']}" height=100px >
                                    <button type="button" onclick="preview(this)" data-url="{$data['pic_path']}" class="btn btn-default">预览</button>
                                </div>
                            </div>
                        </if>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label">上传主图</label>
                            <div class="col-sm-6 v-m">
                                 <!-- 上传组件容器 开始-->
                                <div id="pic_upload" class="xb-uploader">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div class="filePicker"></div>
                                            <p>选择图片</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="progress">
                                            <span class="text">0%</span>
                                            <span class="percentage"></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                    <div class="pic_list" style="display: none;">
                                        <input type="hidden" name="pic_path" value="{$data['pic_path']}" />
                                    </div>
                                </div>
                                <!-- 上传组件容器 结束-->
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label" for="input-id-1">SEO标题</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="seo_title" value="{$data['seo_title']}" data-form-un="1470118834084.755">
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label">SEO关键字</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="seo_keyword" value="{$data['seo_keyword']}" data-form-un="1470118834084.755">
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label">SEO描述</label>
                            <div class="col-sm-6">
                                <textarea type="text" rows="3" class="form-control" name="seo_content" data-form-un="1470118834084.755">{$data['seo_content']}</textarea>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label" for="input-id-1">排序</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="order_number" value="{$data['order_number']}" data-form-un="1470118834084.755">
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label" for="input-id-1">推荐</label>
                            <div class="col-sm-6">
                                <div class="radio">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="is_recommend" value="1" <if condition="$data['is_recommend'] eq 1">checked</if>>
                                        <i></i>是
                                    </label>
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="is_recommend" value="0" <if condition="$data['is_recommend'] eq 0">checked</if>>
                                        <i></i>否
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div role="tabpanel" class="tab-pane" id="profile">
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label" for="input-id-1">名称</label>
                            <label class="col-sm-2 control-label" for="input-id-1">字段名</label>
                            <label class="col-sm-2 control-label" for="input-id-1">类型</label>
                            <label class="col-sm-4 control-label" for="input-id-1">选项（用,隔开）</label>
                            <button id="add_expand" type="button" class="btn btn-default" onclick="addExpand(this)">添加字段</button>
                        </div>
                        <empty name="expand">
                            <div class="line line-dashed b-b line-lg pull-in"></div>
                            <div class="form-group m-b-none m-l-none m-r-none">
                                <input name="expand_id[]" type="hidden" value=""/>
                                <div class="col-sm-2">
                                    <input type="text" class="form-control" name="c_name[]" value="" data-form-un="1470118834084.755">
                                </div>
                                <div class="col-sm-2">
                                    <input type="text" class="form-control" name="e_name[]" value="" data-form-un="1470118834084.755">
                                </div>
                                <div class="col-sm-2">
                                    <select name="type[]" class="form-control">
                                        <option value="input">文字输入</option>
                                        <option value="select">下拉选择</option>
                                    </select>
                                </div>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" name="option[]" value="" data-form-un="1470118834084.755">
                                </div>
                                <button type="button" onclick="delete_expand(this)" data-id="0" class="btn btn-danger">删除</button>
                            </div>
                        <else />
                            <volist name="expand" id="v">
                                <div class="line line-dashed b-b line-lg pull-in"></div>
                                <div class="form-group m-b-none m-l-none m-r-none">
                                    <input name="expand_id[]" type="hidden" value="{$v['id']}"/>
                                    <div class="col-sm-2">
                                        <input type="text" class="form-control" name="c_name[]" value="{$v['c_name']}" data-form-un="1470118834084.755">
                                    </div>
                                    <div class="col-sm-2">
                                        <input type="text" class="form-control" name="e_name[]" value="{$v['e_name']}" data-form-un="1470118834084.755">
                                    </div>
                                    <div class="col-sm-2">
                                        <select name="type[]" class="form-control">
                                            <option value="input" <if condition="$v['type'] eq 'input'">selected</if>>文字输入</option>
                                            <option value="select" <if condition="$v['type'] eq 'select'">selected</if>>下拉选择</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" name="option[]" value="{$v['option']}" data-form-un="1470118834084.755">
                                    </div>
                                    <button type="button" onclick="delete_expand(this)" data-id="0" class="btn btn-danger">删除</button>
                                </div>
                            </volist>
                        </empty>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label" for="input-id-1">同步至子分类：</label>
                            <div class="col-sm-6">
                                <div class="radio">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="expand_synchronized" value="1">
                                        <i></i>是
                                    </label>
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="expand_synchronized" value="0" checked>
                                        <i></i>否
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div role="tabpanel" class="tab-pane" id="config">
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label" for="input-id-1">内容：</label>
                            <div class="col-sm-6">
                                <div class="radio">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="content" value="1" <if condition="$data['content'] eq 1">checked</if>>
                                        <i></i>显示
                                    </label>
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="content" value="0" <if condition="$data['content'] eq 0">checked</if>>
                                        <i></i>隐藏
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label" for="input-id-1">SEO设置：</label>
                            <div class="col-sm-6">
                                <div class="radio">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="seo" value="1" <if condition="$data['seo'] eq 1">checked</if>>
                                        <i></i>显示
                                    </label>
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="seo" value="0" <if condition="$data['seo'] eq 0">checked</if>>
                                        <i></i>隐藏
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label" for="input-id-1">附件：</label>
                            <div class="col-sm-6">
                                <div class="radio">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="attachment" value="1" <if condition="$data['attachment'] eq 1">checked</if>>
                                        <i></i>显示
                                    </label>
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="attachment" value="0" <if condition="$data['attachment'] eq 0">checked</if>>
                                        <i></i>隐藏
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label" for="input-id-1">相册：</label>
                            <div class="col-sm-6">
                                <div class="radio">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="album" value="1" <if condition="$data['album'] eq 1">checked</if>>
                                        <i></i>显示
                                    </label>
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="album" value="0" <if condition="$data['album'] eq 0">checked</if>>
                                        <i></i>隐藏
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label" for="input-id-1">地址：</label>
                            <div class="col-sm-6">
                                <div class="radio">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="address" value="1" <if condition="$data['address'] eq 1">checked</if>>
                                        <i></i>显示
                                    </label>
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="address" value="0" <if condition="$data['address'] eq 0">checked</if>>
                                        <i></i>隐藏
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label" for="input-id-1">同步至子分类：</label>
                            <div class="col-sm-6">
                                <div class="radio">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="config_synchronized" value="1">
                                        <i></i>是
                                    </label>
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="config_synchronized" value="0" checked>
                                        <i></i>否
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="line line-dashed b-b line-lg pull-in"></div>               
                    <div class="form-group m-l-none m-r-none">  
                        <div class="col-sm-4 col-sm-offset-2">
                            <button type="submit" class="btn btn-primary">提交</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<div class="modal fade" id="preview" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
         <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    图片预览
                </h4>
            </div>
            <div class="modal-body">
                <img src='' class="b b-a wrapper-xs bg-white img-responsive">
            </div>
        </div>
    </div>
</div>
<script src="__ADMIN_STATICS__/jquery/jquery.min.js"></script>
<script src="__ADMIN_STATICS__/bootstrap/dist/js/bootstrap.js"></script>
<script src="__ADMIN_STATICS__/webuploader-0.1.5/webuploader.js"></script>
<script src="__ADMIN_STATICS__/webuploader-0.1.5/uploaderSf.js"></script>  
<script type="text/javascript">
upload_init('pic', false, 'image');
function upload_init(activeTab,multiple,type){
     $('#'+activeTab+'_upload').sfUpload({
        url:"/index.php?m=Admin&c=Article&a=upload&type="+type,
        picker:activeTab+'_upload',
        multiple:multiple,
        sizeLimit:1,
        success:function( data ) {
            $("input[name='"+activeTab+"_path']").val(data.path);
            console.log(data);
        },
        error:function( err ) {
            console.info( err );    
        }
    });
}
function preview(obj){
    var path = $(obj).attr('data-url');
    $('#preview img').attr('src', path);
    $('#preview').modal('show');
}

function addExpand(obj){
    var str = '<div class="line line-dashed b-b line-lg pull-in"></div><div class="form-group m-b-none m-l-none m-r-none"><input name="expand_id[]" type="hidden" value=""/><div class="col-sm-2"><input type="text" class="form-control" name="c_name[]" value="" data-form-un="1470118834084.755"></div><div class="col-sm-2"><input type="text" class="form-control" name="e_name[]" value="" data-form-un="1470118834084.755"></div><div class="col-sm-2"><select name="type[]" class="form-control"><option value="input">文字输入</option><option value="select">下拉选择</option></select></div><div class="col-sm-4"><input type="text" class="form-control" name="option[]" value="" data-form-un="1470118834084.755"></div><button type="button" onclick="delete_expand(this)" data-id="0" class="btn btn-danger">删除</button></div>';
    $('#profile').append(str);
}

function delete_expand(obj){
    var id = $(obj).attr('data-id');
    if(id == 0){
       $(obj).parent().prev().remove();
       $(obj).parent().remove();
    }else{
        $.ajax({
            type : 'post',
            url : "{:U('Admin/ArticleCategory/delete_expand')}",
            data : {id:id},
            dataType : 'json',
            success : function(data){
                if (data.code) {
                    $(obj).parent().prev().remove();
                    $(obj).parent().remove();
                }else{
                    alert(data.msg);
                }
            }
        });
    }
}
</script>
</body>
</html>
